using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication11.Models.Mapping
{
    public class patientMap : EntityTypeConfiguration<patient>
    {
        public patientMap()
        {
            // Primary Key
            this.HasKey(t => t.patient_id);

            // Properties
            this.Property(t => t.patient_id)
                .IsRequired()
                .HasMaxLength(20);

            this.Property(t => t.new_id)
                .IsFixedLength()
                .HasMaxLength(4);

            this.Property(t => t.name)
                .IsRequired()
                .HasMaxLength(30);

            this.Property(t => t.id_card)
                .IsRequired()
                .HasMaxLength(20);

            this.Property(t => t.address)
                .HasMaxLength(100);

            this.Property(t => t.postcode)
                .HasMaxLength(6);

            this.Property(t => t.phone)
                .HasMaxLength(20);

            this.Property(t => t.is_transferred)
                .HasMaxLength(1);

            this.Property(t => t.transferred_from)
                .HasMaxLength(100);

            this.Property(t => t.occupation)
                .HasMaxLength(50);

            this.Property(t => t.cell_phone)
                .HasMaxLength(20);

            this.Property(t => t.email)
                .HasMaxLength(50);

            this.Property(t => t.assigned_medical_unit)
                .HasMaxLength(100);

            this.Property(t => t.know_ht_before)
                .HasMaxLength(1);

            this.Property(t => t.is_check_agree)
                .HasMaxLength(1);

            this.Property(t => t.create_by)
                .HasMaxLength(20);

            this.Property(t => t.diagnosed_hospital)
                .HasMaxLength(100);

            this.Property(t => t.family_history_hypertension)
                .HasMaxLength(1);

            this.Property(t => t.family_history_hypertension_date)
                .HasMaxLength(4);

            this.Property(t => t.family_history_hypertension_age)
                .HasMaxLength(1);

            this.Property(t => t.family_history_chf)
                .HasMaxLength(1);

            this.Property(t => t.family_history_chf_date)
                .HasMaxLength(4);

            this.Property(t => t.family_history_stroke)
                .HasMaxLength(1);

            this.Property(t => t.family_history_diabetes)
                .HasMaxLength(1);

            this.Property(t => t.family_history_none_of_above)
                .HasMaxLength(1);

            this.Property(t => t.family_history_unknown)
                .HasMaxLength(1);

            this.Property(t => t.family_history_not_answer)
                .HasMaxLength(1);

            this.Property(t => t.family_history_other)
                .HasMaxLength(1);

            this.Property(t => t.family_history_other_detail)
                .HasMaxLength(100);

            this.Property(t => t.allergy_history)
                .HasMaxLength(1);

            this.Property(t => t.allergy_detail)
                .HasMaxLength(100);

            this.Property(t => t.complication_stroke_clot)
                .HasMaxLength(1);

            this.Property(t => t.complication_stroke_bleed)
                .HasMaxLength(1);

            this.Property(t => t.complication_stroke_tia)
                .HasMaxLength(1);

            this.Property(t => t.complication_heart_attack)
                .HasMaxLength(1);

            this.Property(t => t.complication_angina_pectoris)
                .HasMaxLength(1);

            this.Property(t => t.complication_heart_failure)
                .HasMaxLength(1);

            this.Property(t => t.complication_ht_related_kidney_disease)
                .HasMaxLength(1);

            this.Property(t => t.complication_kidney_failure)
                .HasMaxLength(1);

            this.Property(t => t.complication_dissecting_aneurysm)
                .HasMaxLength(1);

            this.Property(t => t.complication_disease_symptomatic)
                .HasMaxLength(1);

            this.Property(t => t.complication_hemorrhage)
                .HasMaxLength(1);

            this.Property(t => t.complication_papilledem)
                .HasMaxLength(1);

            this.Property(t => t.complication_other)
                .HasMaxLength(1);

            this.Property(t => t.complication_other_detail)
                .HasMaxLength(100);

            this.Property(t => t.update_by)
                .HasMaxLength(20);

            this.Property(t => t.main_diagose_hospital)
                .HasMaxLength(200);

            this.Property(t => t.reason_not_goto_ch_medical)
                .HasMaxLength(1);

            this.Property(t => t.reason_not_goto_ch_finance)
                .HasMaxLength(1);

            this.Property(t => t.reason_not_goto_ch_hospital)
                .HasMaxLength(1);

            this.Property(t => t.reason_not_goto_ch_other)
                .HasMaxLength(1);

            this.Property(t => t.reason_not_goto_ch_other_desc)
                .HasMaxLength(50);

            this.Property(t => t.disease_chf)
                .HasMaxLength(1);

            this.Property(t => t.disease_stoke)
                .HasMaxLength(1);

            this.Property(t => t.disease_diabetes)
                .HasMaxLength(1);

            this.Property(t => t.disease_diabetes_date)
                .HasMaxLength(4);

            this.Property(t => t.family_history_diabetes_level)
                .HasMaxLength(1);

            this.Property(t => t.disease_none_of_above)
                .HasMaxLength(1);

            this.Property(t => t.disease_unknown)
                .HasMaxLength(1);

            this.Property(t => t.disease_not_answer)
                .HasMaxLength(1);

            this.Property(t => t.disease_other)
                .HasMaxLength(1);

            this.Property(t => t.disease_other_detail)
                .HasMaxLength(100);

            this.Property(t => t.doctor_id)
                .IsRequired()
                .HasMaxLength(20);

            this.Property(t => t.duty_doctor)
                .HasMaxLength(20);

            this.Property(t => t.alternate_contact)
                .HasMaxLength(50);

            this.Property(t => t.alternate_contact_desc)
                .HasMaxLength(100);

            this.Property(t => t.disease_cardiac_intervention)
                .HasMaxLength(1);

            this.Property(t => t.disease_retinopathy)
                .HasMaxLength(1);

            this.Property(t => t.disease_heart_failure)
                .HasMaxLength(1);

            this.Property(t => t.disease_dissecting_aneurysm)
                .HasMaxLength(1);

            this.Property(t => t.disease_tumour)
                .HasMaxLength(1);

            this.Property(t => t.emergency_contact_number1)
                .HasMaxLength(11);

            this.Property(t => t.emergency_contact_number2)
                .HasMaxLength(11);

            this.Property(t => t.risk_factors_hypertension)
                .HasMaxLength(1);

            this.Property(t => t.risk_factors_hypertension_date)
                .HasMaxLength(4);

            this.Property(t => t.risk_factors_hypertension_level)
                .HasMaxLength(1);

            this.Property(t => t.risk_factors_hyperlipidemia)
                .HasMaxLength(1);

            this.Property(t => t.risk_factors_hyperlipidemia_date)
                .HasMaxLength(4);

            this.Property(t => t.recordNumber)
                .HasMaxLength(50);

            this.Property(t => t.disease_diabetes_level)
                .HasMaxLength(50);

            this.Property(t => t.Province)
                .HasMaxLength(50);

            this.Property(t => t.City)
                .HasMaxLength(50);

            this.Property(t => t.Area)
                .HasMaxLength(50);

            this.Property(t => t.IsEnable)
                .IsFixedLength()
                .HasMaxLength(4);

            this.Property(t => t.PYM)
                .HasMaxLength(20);

            // Table & Column Mappings
            this.ToTable("patient");
            this.Property(t => t.patient_id).HasColumnName("patient_id");
            this.Property(t => t.new_id).HasColumnName("new_id");
            this.Property(t => t.name).HasColumnName("name");
            this.Property(t => t.gender).HasColumnName("gender");
            this.Property(t => t.id_card).HasColumnName("id_card");
            this.Property(t => t.birth_date).HasColumnName("birth_date");
            this.Property(t => t.address).HasColumnName("address");
            this.Property(t => t.postcode).HasColumnName("postcode");
            this.Property(t => t.phone).HasColumnName("phone");
            this.Property(t => t.is_transferred).HasColumnName("is_transferred");
            this.Property(t => t.transferred_from).HasColumnName("transferred_from");
            this.Property(t => t.race_id).HasColumnName("race_id");
            this.Property(t => t.marital_status_id).HasColumnName("marital_status_id");
            this.Property(t => t.education_id).HasColumnName("education_id");
            this.Property(t => t.occupation).HasColumnName("occupation");
            this.Property(t => t.cell_phone).HasColumnName("cell_phone");
            this.Property(t => t.email).HasColumnName("email");
            this.Property(t => t.assigned_medical_unit).HasColumnName("assigned_medical_unit");
            this.Property(t => t.medical_expenses_payer_id).HasColumnName("medical_expenses_payer_id");
            this.Property(t => t.join_group_type).HasColumnName("join_group_type");
            this.Property(t => t.know_ht_before).HasColumnName("know_ht_before");
            this.Property(t => t.patient_group).HasColumnName("patient_group");
            this.Property(t => t.is_check_agree).HasColumnName("is_check_agree");
            this.Property(t => t.create_by).HasColumnName("create_by");
            this.Property(t => t.create_time).HasColumnName("create_time");
            this.Property(t => t.status).HasColumnName("status");
            this.Property(t => t.ht_type_id).HasColumnName("ht_type_id");
            this.Property(t => t.diagnosed_sbp).HasColumnName("diagnosed_sbp");
            this.Property(t => t.diagnosed_dbp).HasColumnName("diagnosed_dbp");
            this.Property(t => t.diagnosed_hospital).HasColumnName("diagnosed_hospital");
            this.Property(t => t.diagnosed_date).HasColumnName("diagnosed_date");
            this.Property(t => t.family_history_hypertension).HasColumnName("family_history_hypertension");
            this.Property(t => t.family_history_hypertension_date).HasColumnName("family_history_hypertension_date");
            this.Property(t => t.family_history_hypertension_age).HasColumnName("family_history_hypertension_age");
            this.Property(t => t.family_history_chf).HasColumnName("family_history_chf");
            this.Property(t => t.family_history_chf_date).HasColumnName("family_history_chf_date");
            this.Property(t => t.family_history_stroke).HasColumnName("family_history_stroke");
            this.Property(t => t.family_history_diabetes).HasColumnName("family_history_diabetes");
            this.Property(t => t.family_history_none_of_above).HasColumnName("family_history_none_of_above");
            this.Property(t => t.family_history_unknown).HasColumnName("family_history_unknown");
            this.Property(t => t.family_history_not_answer).HasColumnName("family_history_not_answer");
            this.Property(t => t.family_history_other).HasColumnName("family_history_other");
            this.Property(t => t.family_history_other_detail).HasColumnName("family_history_other_detail");
            this.Property(t => t.allergy_history).HasColumnName("allergy_history");
            this.Property(t => t.allergy_detail).HasColumnName("allergy_detail");
            this.Property(t => t.complication_stroke_clot).HasColumnName("complication_stroke_clot");
            this.Property(t => t.complication_stroke_bleed).HasColumnName("complication_stroke_bleed");
            this.Property(t => t.complication_stroke_tia).HasColumnName("complication_stroke_tia");
            this.Property(t => t.complication_heart_attack).HasColumnName("complication_heart_attack");
            this.Property(t => t.complication_angina_pectoris).HasColumnName("complication_angina_pectoris");
            this.Property(t => t.complication_heart_failure).HasColumnName("complication_heart_failure");
            this.Property(t => t.complication_ht_related_kidney_disease).HasColumnName("complication_ht_related_kidney_disease");
            this.Property(t => t.complication_kidney_failure).HasColumnName("complication_kidney_failure");
            this.Property(t => t.complication_dissecting_aneurysm).HasColumnName("complication_dissecting_aneurysm");
            this.Property(t => t.complication_disease_symptomatic).HasColumnName("complication_disease_symptomatic");
            this.Property(t => t.complication_hemorrhage).HasColumnName("complication_hemorrhage");
            this.Property(t => t.complication_papilledem).HasColumnName("complication_papilledem");
            this.Property(t => t.complication_other).HasColumnName("complication_other");
            this.Property(t => t.complication_other_detail).HasColumnName("complication_other_detail");
            this.Property(t => t.update_by).HasColumnName("update_by");
            this.Property(t => t.update_time).HasColumnName("update_time");
            this.Property(t => t.bp_class_id).HasColumnName("bp_class_id");
            this.Property(t => t.bp_level_id).HasColumnName("bp_level_id");
            this.Property(t => t.bp_group_id).HasColumnName("bp_group_id");
            this.Property(t => t.main_diagose_hospital).HasColumnName("main_diagose_hospital");
            this.Property(t => t.times_goto_community_hospital).HasColumnName("times_goto_community_hospital");
            this.Property(t => t.times_goto_hospital).HasColumnName("times_goto_hospital");
            this.Property(t => t.reason_not_goto_ch_medical).HasColumnName("reason_not_goto_ch_medical");
            this.Property(t => t.reason_not_goto_ch_finance).HasColumnName("reason_not_goto_ch_finance");
            this.Property(t => t.reason_not_goto_ch_hospital).HasColumnName("reason_not_goto_ch_hospital");
            this.Property(t => t.reason_not_goto_ch_other).HasColumnName("reason_not_goto_ch_other");
            this.Property(t => t.reason_not_goto_ch_other_desc).HasColumnName("reason_not_goto_ch_other_desc");
            this.Property(t => t.disease_chf).HasColumnName("disease_chf");
            this.Property(t => t.disease_stoke).HasColumnName("disease_stoke");
            this.Property(t => t.disease_diabetes).HasColumnName("disease_diabetes");
            this.Property(t => t.disease_diabetes_date).HasColumnName("disease_diabetes_date");
            this.Property(t => t.family_history_diabetes_level).HasColumnName("family_history_diabetes_level");
            this.Property(t => t.disease_none_of_above).HasColumnName("disease_none_of_above");
            this.Property(t => t.disease_unknown).HasColumnName("disease_unknown");
            this.Property(t => t.disease_not_answer).HasColumnName("disease_not_answer");
            this.Property(t => t.disease_other).HasColumnName("disease_other");
            this.Property(t => t.disease_other_detail).HasColumnName("disease_other_detail");
            this.Property(t => t.doctor_id).HasColumnName("doctor_id");
            this.Property(t => t.duty_doctor).HasColumnName("duty_doctor");
            this.Property(t => t.node_id).HasColumnName("node_id");
            this.Property(t => t.alternate_contact).HasColumnName("alternate_contact");
            this.Property(t => t.alternate_contact_desc).HasColumnName("alternate_contact_desc");
            this.Property(t => t.card_type_id).HasColumnName("card_type_id");
            this.Property(t => t.hospital_grade).HasColumnName("hospital_grade");
            this.Property(t => t.disease_cardiac_intervention).HasColumnName("disease_cardiac_intervention");
            this.Property(t => t.disease_retinopathy).HasColumnName("disease_retinopathy");
            this.Property(t => t.disease_heart_failure).HasColumnName("disease_heart_failure");
            this.Property(t => t.disease_dissecting_aneurysm).HasColumnName("disease_dissecting_aneurysm");
            this.Property(t => t.disease_tumour).HasColumnName("disease_tumour");
            this.Property(t => t.emergency_contact_number1).HasColumnName("emergency_contact_number1");
            this.Property(t => t.emergency_contact_number2).HasColumnName("emergency_contact_number2");
            this.Property(t => t.risk_factors_hypertension).HasColumnName("risk_factors_hypertension");
            this.Property(t => t.risk_factors_hypertension_date).HasColumnName("risk_factors_hypertension_date");
            this.Property(t => t.risk_factors_hypertension_level).HasColumnName("risk_factors_hypertension_level");
            this.Property(t => t.risk_factors_hyperlipidemia).HasColumnName("risk_factors_hyperlipidemia");
            this.Property(t => t.risk_factors_hyperlipidemia_date).HasColumnName("risk_factors_hyperlipidemia_date");
            this.Property(t => t.recordNumber).HasColumnName("recordNumber");
            this.Property(t => t.disease_diabetes_level).HasColumnName("disease_diabetes_level");
            this.Property(t => t.Province).HasColumnName("Province");
            this.Property(t => t.City).HasColumnName("City");
            this.Property(t => t.Area).HasColumnName("Area");
            this.Property(t => t.IsEnable).HasColumnName("IsEnable");
            this.Property(t => t.PYM).HasColumnName("PYM");

            // Relationships
            this.HasOptional(t => t.bp_class_para)
                .WithMany(t => t.patients)
                .HasForeignKey(d => d.bp_class_id);
            this.HasOptional(t => t.bp_group_para)
                .WithMany(t => t.patients)
                .HasForeignKey(d => d.bp_group_id);
            this.HasOptional(t => t.bp_level_para)
                .WithMany(t => t.patients)
                .HasForeignKey(d => d.bp_level_id);

        }
    }
}
